package June;

import java.util.Scanner;

public class Test04String02_2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str;
        while (true) {
            System.out.println("请输入一个字符串");
            str = sc.next();
            boolean flag = checkStr(str);
            if (flag) {
                break;
            } else {
                System.out.println("当前的字符串不符合规则，请重新输入");
                continue;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int number = c - 48;
            String s = changeLuoMa(c);
            sb.append(s);
        }
        System.out.print(sb);
    }

    public static String changeLuoMa(char number) {
        String str;
        switch (number) {
            case '1':
                str = "Ⅰ";
                break;
            case '2':
                str = "Ⅱ";
                break;
            case '3':
                str = "Ⅲ";
                break;
            case '4':
                str = "Ⅳ";
                break;
            case '5':
                str = "Ⅴ";
                break;
            case '6':
                str = "Ⅵ";
                break;
            case '7':
                str = "Ⅶ";
                break;
            case '8':
                str = "Ⅷ";
                break;
            case '9':
                str = "Ⅸ";
                break;
            case '0':
            default:
                str = "";
                break;
        }
        return str;
    }

    public static boolean checkStr(String str) {
        //长度需要小于9
        if (str.length() > 9) {
            return false;
        }

        //只能是数字
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c < '0' || c > '9') {
                return false;
            }
        }
        //只有当字符串里的所有字符全部判断完毕，才能返回true
        return true;
    }
}
